/*   1:    */ package com.rinsi.util;
/*   2:    */ 
/*   3:    */ import java.text.ParseException;
/*   4:    */ import java.util.Date;
/*   5:    */ import java.util.Enumeration;
/*   6:    */ import java.util.HashMap;
/*   7:    */ import java.util.List;
/*   8:    */ import java.util.Map;
/*   9:    */ import javax.servlet.http.HttpServletRequest;
/*  10:    */ import javax.servlet.http.HttpSession;
/*  11:    */ import org.codehaus.jackson.map.ObjectMapper;
/*  12:    */ 
/*  13:    */ public class MapUtil
/*  14:    */ {
/*  15:    */   public static Map<String, Object> createParamsMap(HttpServletRequest request)
/*  16:    */   {
/*  17: 38 */     Map<String, Object> map = new HashMap();
/*  18:    */     
/*  19: 40 */     Enumeration<String> attrs = request.getParameterNames();
/*  20: 42 */     while (attrs.hasMoreElements())
/*  21:    */     {
/*  22: 44 */       String key = (String)attrs.nextElement();
/*  23:    */       
/*  24: 46 */       map.put(key, request.getParameter(key));
/*  25:    */     }
/*  26: 50 */     return map;
/*  27:    */   }
/*  28:    */   
/*  29:    */   public static Map<String, Object> createSessionMap(HttpServletRequest request)
/*  30:    */   {
/*  31: 62 */     Map<String, Object> map = new HashMap();
/*  32:    */     
/*  33: 64 */     Enumeration<String> attrs = request.getSession().getAttributeNames();
/*  34: 66 */     while (attrs.hasMoreElements())
/*  35:    */     {
/*  36: 68 */       String key = (String)attrs.nextElement();
/*  37:    */       
/*  38: 70 */       map.put(key, request.getSession().getAttribute(key));
/*  39:    */     }
/*  40: 74 */     return map;
/*  41:    */   }
/*  42:    */   
/*  43:    */   public static Map<String, Object> createAttrMap(HttpServletRequest request)
/*  44:    */   {
/*  45: 86 */     Map<String, Object> map = new HashMap();
/*  46:    */     
/*  47: 88 */     Enumeration<String> attrs = request.getAttributeNames();
/*  48: 90 */     while (attrs.hasMoreElements())
/*  49:    */     {
/*  50: 92 */       String key = (String)attrs.nextElement();
/*  51:    */       
/*  52: 94 */       map.put(key, request.getAttribute(key));
/*  53:    */     }
/*  54: 98 */     return map;
/*  55:    */   }
/*  56:    */   
/*  57:    */   public static Map<String, Object> createConfigMap()
/*  58:    */   {
/*  59:108 */     return ConfigUtil.config();
/*  60:    */   }
/*  61:    */   
/*  62:    */   public static Map<String, Object> createConfigMap(Class<?> clazz)
/*  63:    */   {
/*  64:118 */     return ConfigUtil.config(clazz);
/*  65:    */   }
/*  66:    */   
/*  67:    */   public static Map<String, Object> createReturnMap(Boolean success)
/*  68:    */   {
/*  69:128 */     Map<String, Object> map = new HashMap();
/*  70:    */     
/*  71:130 */     map.put("success", success);
/*  72:    */     
/*  73:132 */     map.put("message", success.booleanValue() ? "请求处理成功！" : "请求处理失败");
/*  74:    */     
/*  75:134 */     return map;
/*  76:    */   }
/*  77:    */   
/*  78:    */   public static String getString(Map<String, Object> map, String key)
/*  79:    */   {
/*  80:145 */     return FormaterUtil.stringValue(map.get(key));
/*  81:    */   }
/*  82:    */   
/*  83:    */   public static Integer getInteger(Map<String, Object> map, String key)
/*  84:    */   {
/*  85:157 */     return FormaterUtil.integerValue(map.get(key));
/*  86:    */   }
/*  87:    */   
/*  88:    */   public static Float getFloat(Map<String, Object> map, String key)
/*  89:    */   {
/*  90:169 */     return FormaterUtil.floatValue(map.get(key));
/*  91:    */   }
/*  92:    */   
/*  93:    */   public static Boolean getBoolean(Map<String, Object> map, String key)
/*  94:    */   {
/*  95:181 */     return FormaterUtil.booleanValue(map.get(key));
/*  96:    */   }
/*  97:    */   
/*  98:    */   public static Date getDate(Map<String, Object> map, String key, String formater)
/*  99:    */     throws ParseException
/* 100:    */   {
/* 101:197 */     return FormaterUtil.dateValue(map.get(key), formater);
/* 102:    */   }
/* 103:    */   
/* 104:    */   public static Date getDate(Map<String, Object> map, String key)
/* 105:    */     throws ParseException
/* 106:    */   {
/* 107:211 */     return FormaterUtil.dateValue(map.get(key));
/* 108:    */   }
/* 109:    */   
/* 110:    */   public static String getFormatDate(Map<String, Object> map, String key, String formater)
/* 111:    */   {
/* 112:225 */     return FormaterUtil.formatDateValue(map.get(key), formater);
/* 113:    */   }
/* 114:    */   
/* 115:    */   public static String getFormatDate(Map<String, Object> map, String key)
/* 116:    */   {
/* 117:237 */     return FormaterUtil.formatDateValue(map.get(key));
/* 118:    */   }
/* 119:    */   
/* 120:    */   public static Map<String, Object> getMapData(Map<String, Object> map, String key)
/* 121:    */   {
/* 122:250 */     return (Map)map.get(key);
/* 123:    */   }
/* 124:    */   
/* 125:    */   public static List<Map<String, Object>> getListDatas(Map<String, Object> map, String key)
/* 126:    */   {
/* 127:263 */     return (List)map.get(key);
/* 128:    */   }
/* 129:    */   
/* 130:    */   public static String json(Map<String, Object> map)
/* 131:    */   {
/* 132:    */     try
/* 133:    */     {
/* 134:274 */       ObjectMapper objectMapper = new ObjectMapper();
/* 135:    */       
/* 136:276 */       return objectMapper.writeValueAsString(map).replace("null", "\"\"").replace("NULL", "\"\"");
/* 137:    */     }
/* 138:    */     catch (Exception e)
/* 139:    */     {
/* 140:280 */       e.printStackTrace();
/* 141:    */     }
/* 142:283 */     return "";
/* 143:    */   }
/* 144:    */   
/* 145:    */   public static boolean has(Map<String, Object> map, String key)
/* 146:    */   {
/* 147:288 */     if (AssertUtil.isMapNotEmpty(map)) {
/* 148:290 */       return map.containsKey(key);
/* 149:    */     }
/* 150:292 */     return false;
/* 151:    */   }
/* 152:    */   
/* 153:    */   public static boolean isNotEmpty(Map<String, Object> map)
/* 154:    */   {
/* 155:297 */     return AssertUtil.isMapNotEmpty(map);
/* 156:    */   }
/* 157:    */ }


/* Location:           D:\Users\Desktop\shanxi\项目\sxazmis\WEB-INF\classes\
 * Qualified Name:     com.rinsi.util.MapUtil
 * JD-Core Version:    0.7.0.1
 */